home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / ai.prl / dprolog.lha / mother.pro < prev    next >
Text File  |  1991-03-05  |  1KB  |  45 lines

  1. /*  MOTHER
  2.     A d-Prolog Database
  3.     Copyright (C) Donald Nute
  4.  
  5. Mother is unhappy when baby cries, and normally mother is happy
  6. when baby isn't crying.  Baby normally doesn't cry when the
  7. little girl next door plays with her.  At a certain time, the
  8. little girl next door played with baby.  We would expect mother
  9. to be happy.  However, the little girl next door has measles.
  10. This should defeat our conclusion that mother is happy.  For this
  11. to happen, we need some background knowledge.  First, measles is
  12. an infectious disease.  Second, anyone who comes near a person
  13. with an infectious disease is exposed to infection.  Third,
  14. anyone with whom a person plays comes near that person.  Finally,
  15. mother is unhappy when baby is exposed to an infectious disease.
  16.  
  17. We represent these facts in a d-Prolog database.               */
  18.  
  19.     happy(mother,T):=
  20.         neg crying(baby,T).
  21.  
  22.     neg crying(baby,T):=
  23.         plays_with(little_girl_next_door,baby,T).
  24.  
  25.     plays_with(little_girl_next_door,baby,t).
  26.  
  27.     has(little_girl_next_door,measles,t).
  28.  
  29.     infectious_disease(measles).
  30.  
  31.     near(X,Y,T):-
  32.         plays_with(Y,X,T).
  33.  
  34.     exposed_to_infection(X,T):=
  35.         near(X,Y,T),
  36.         has(Y,Z,T),
  37.         infectious_disease(Z).
  38.  
  39.     neg happy(mother,T):=
  40.         exposed_to_infection(baby,T).
  41.  
  42. /*  Can we infer that mother is happy at time t?  That is, does
  43.     the d-Prolog goal '@ happy(mother,t)' succeed?             */
  44.  
  45.